﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DealerJudge.Core;
using System.Data.SqlServerCe;

namespace DealerJudge.Data
{
    public class ConnectionProvider : IConnectionProvider
    {
        private readonly ILogger _logger;
        private readonly IConfigManager _configManager;

        public ConnectionProvider(ILogger logger, IConfigManager configManager)
        {
            _logger = logger;
            _configManager = configManager;
        }

        public IDatabaseConnection CreateDatabaseConnection()
        {
            IDatabaseConnection conn = null;
            string connectionString;

            connectionString = _configManager.GetConnectionString();

            conn = new DatabaseConnection(new SqlConnection(connectionString));
            //conn = new DatabaseConnection(new SqlCeConnection(connectionString));

            return conn;
        }
        public IDbDataAdapter CreateDataAdapter()
        {
            //return new SqlDataAdapter();
            return new SqlCeDataAdapter();
        }
    }
}
